package com.zoe.onelink.actuate.info;

import com.zoe.onelink.common.constant.AppEnvConstant;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.core.env.Environment;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2022</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2022-05-09
 */
@RequiredArgsConstructor
public class OnelinkEnvInfoContributor implements InfoContributor {

    private static final String UNKNOWN = "unknown";
    private final Environment environment;

    @Override
    public void contribute(Info.Builder builder) {
        builder.withDetail(AppEnvConstant.APP_VERSION_PROJECT, this.environment.getProperty(AppEnvConstant.APP_VERSION_PROJECT, UNKNOWN));
        builder.withDetail(AppEnvConstant.APP_BRANCH_NAME, this.environment.getProperty(AppEnvConstant.APP_BRANCH_NAME, UNKNOWN));
    }
}
